var App = require('app');

App.AppRoute = Ember.Route.extend({
	model: function(params) {
		if (Util.isNotEmpty(params.app_id)) {
			Vari.CurrAppId = params.app_id;
			Vari.app = AppUtil.retriveInfo(Vari.CurrAppId);
			return Vari.app;
		}else {
			var app = AppUtil.newApp();
			Vari.CurrAppId = app.get("id");
			Vari.app = app;
			return Vari.app; 
		}
	},
	setupController : function(controller, model) {
		
	},	
});


App.AppEditRoute = Ember.Route.extend({
	model: function(params) {
		
	},
	setupController : function(controller, model) {
		Vari.app = AppUtil.retriveInfo(Vari.CurrAppId);
		controller.set('content', Vari.app);
	},
	
});

App.AppRunRoute = Ember.Route.extend({
	model: function(params) {
		
	},
	setupController : function(controller, model) {
		var forms = FormUtil.retriveList(Vari.CurrAppId);
		controller.set('content', {app:Vari.app, forms: forms});
	},
	
});
